/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Author: Huawei OS Kernel Lab
 * Create: Thu Aug 15 16:14:23 2023
 */

#ifndef __LIBLINUX_SYSFS_H__
#define __LIBLINUX_SYSFS_H__

#ifdef CONFIG_LIBLINUX
#include <liblinux/kernfs.h>

#ifndef CONFIG_LIBLINUX_ASYNC_SYSFS
static inline int liblinux_sysfs_create_dir(const char *name, unsigned int mode)
{
	return liblinux_pal_sysfs_create_dir(name, mode);
}

static inline int liblinux_sysfs_create_file(const char *name, unsigned int mode,
					     struct liblinux_pal_kernfs_ops *fops,
					     void *ctx)
{
	return liblinux_pal_sysfs_create_file(name, mode, fops, ctx);
}

static inline int liblinux_sysfs_create_link(const char *name, unsigned int mode,
					     const char *linkdata)
{
	return liblinux_pal_sysfs_create_link(name, mode, linkdata);
}

static inline int liblinux_sysfs_delete(const char *name)
{
	return liblinux_pal_sysfs_delete(name);
}

static inline void liblinux_sysfs_async_init(void)
{
}
#else
int liblinux_sysfs_create_dir(const char *name, unsigned int mode);
int liblinux_sysfs_create_file(const char *name, unsigned int mode,
			       struct liblinux_pal_kernfs_ops *fops, void *ctx);
int liblinux_sysfs_create_link(const char *name, unsigned int mode, const char *linkdata);
int liblinux_sysfs_delete(const char *name);
void liblinux_sysfs_async_init(void);
#endif

static inline void flush_sysfs_wq_no_destroy(void) {}

static inline int liblinux_sysfs_notify(const void *ctx, const char *name)
{
	return liblinux_pal_sysfs_notify(ctx, name);
}

void liblinux_destroy_sysfs_blacklist(void);
int liblinux_add_sysfs_blacklist(char *path, unsigned int len, char *filter[], unsigned int count);

#endif /* CONFIG_LIBLINUX */
#endif /* __LIBLINUX_SYSFS_H__ */
